import type { IModalConfig } from '@/components/page-modal'

const modalConfig: IModalConfig = {
  pageName: 'role',
  header: {
    newTitle: '新建角色',
    editTitle: '编辑角色'
  },
  formIsInline: false,
  formlabelWidth: '80',
  modalWidth: '30%',
  // formIsInline: true,
  // formlabelWidth: '50',
  // modalWidth: '40%',
  formItems: [
    {
      type: 'input',
      prop: 'name',
      label: '角色名称',
      placeholder: '请输入角色名称',
      initalValue: '',
      // lg: 8,
      // md: 8,
      // sm: 12,
      span: 24,
      rules: [
        { required: true, message: '请输入角色名称', trigger: 'blur' },
        {
          message: '请输入角色名称不能少于3位',
          validator: (_rule: any, value: any, cb: Function) => {
            if (value && value.length < 3) {
              cb(new Error('请输入角色名称不能少于3位'))
            } else {
              cb()
            }
          },
          trigger: ['change']
        }
      ]
    },
    {
      type: 'textarea',
      prop: 'intro',
      label: '角色介绍',
      placeholder: '请输入角色介绍',
      initalValue: '',
      // lg: 8,
      // md: 8,
      // sm: 12
      span: 24
    },
    {
      type: 'custom',
      label: '角色权限',
      prop: 'menuList',
      slotName: 'menuList',
      isNeedlabel: true,
      span: 24,
      rules: [
        {
          required: true,
          message: '请选择角色权限',
          trigger: 'change',
          validator: (_rule: any, value: any, cb: Function) => {
            if (Object.keys(value).length === 0) {
              cb(new Error('请请选择角色权限'))
            } else if (value.length < 0) {
              cb(new Error('请请选择角色权限'))
            } else {
              cb()
            }
          }
        }
      ]
    },
    {
      type: 'custom',
      // label: '角色权限',
      prop: 'test',
      slotName: 'test',
      // isNeedlabel: true,
      span: 24,
      placeholder: '请输入角色介绍',
      initalValue: ''
    }
  ],
  titleTip: '角色'
}

export default modalConfig
